//
//  WebViewController.m
//  NemoSDKDemo
//
//  Created by 高超 on 2020/7/15.
//  Copyright © 2020 JackYang. All rights reserved.
//

#import "WebViewController.h"
#import <WebKit/WebKit.h>

@interface WebViewController ()
@property (nonatomic, strong) WKWebView *webview;
@end

@implementation WebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIButton *dismissBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [dismissBtn setTitle:@"返回" forState:UIControlStateNormal];
    dismissBtn.frame = CGRectMake(20, 30, 40, 30);
    [dismissBtn addTarget:self action:@selector(dismissWebView) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:dismissBtn];
    
    WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
    
    self.webview = [[WKWebView alloc] initWithFrame:CGRectMake(0, 70, self.view.bounds.size.width, self.view.bounds.size.height-100) configuration:config];

    [self.view addSubview:self.webview];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.webUrl]];
    
    [self.webview loadRequest:request];
}

- (void)dismissWebView {
    [self dismissViewControllerAnimated:YES completion:nil];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
